package com.pr.entity;

/**
 * @description:
 * @projectName:spring-skill
 * @see:com.pr.entity
 * @author:LXC
 * @createTime:2024/6/19 09:49
 * @version:1.0
 */
public class Account {
    private int balance;

    public Account(int balance) {
        this.balance = balance;
    }

    public synchronized void withdraw(int amount){
        if(balance>=amount){
            balance-=amount;
            System.out.println(Thread.currentThread().getName()+" withdrew "+amount+", blance now is "+balance);
        }else {
            System.out.println("Insufficient balance");
        }
    }
}
